Jan 24 2008

We need a package manager like RubyGems for distributing Flex components – Revisited

Tag: AS3, ActionScript, Flex, Ruby, maven, package manager, sproutsDerek Wischusen @ 6:31 am

About a year ago I wrote a post about how the Flex/As3 community needs a package manager like RubyGems for managing libraries and components.

Well, I have some good news. Recently I’ve learned about two potential solutions to this problem.

The first I learned about from a comment on the original post by Luke Bayes. Here is an excerpt:

I’ve been working on ’sprouts’ for the past year and finally landed on an architecture that actually sits on top of Rubygems for package management. Even though we have a functional pre-alpha in the wild right now, we expect to release a production-ready build before the end of January 2008 that will really support versioning via Rubygems the repository.

Check it out: http://www.projectsprouts.org

The second potential solution is a Flex plugin for Maven. It appears that it is still under development, but it looks promising. You can check it out here.


Nov 23 2007

ActionScript 3 Inflector class for pluralizing and singularizing words

Tag: AS3, ActionScript, RailsDerek Wischusen @ 9:08 pm

The as3 Inflector class can be used to pluralize or singularize most words.  It is essentially a direct port of the Rails inflector class.

Here is a little demo Flex app that I put together to demo the classes functionality.

Inflector Demo

You can right click on the app to view the source and grab the class, or you can just click here.


Nov 23 2007

as3Stomp – Project site and source code

Tag: AS3, ActionScript, ActiveMQ, ActiveMessaging, STOMP, Server PushDerek Wischusen @ 7:48 pm

A little while ago I posted about my ActionScript 3 implementation of the STOMP protocol.  Well, I am just now getting around to posting that I created a google project site and released the source.   This version is slightly updated from the one that was included in my example code in the previous post.

 If you have any questions about this project, or if you would like to contribute, please let me know.  Please post any bugs to this issue list.


Nov 23 2007

as3yaml – A YAML 1.1 parser and emitter for ActionScript 3

Tag: AS3, ActionScript, as3yaml, yamlDerek Wischusen @ 7:13 pm

I am pleased to announce the first release of as3yaml, an ActionScript 3 library for parsing and emitting YAML. It is a direct port of Ola Bini’s jvyaml, which was itself a port of Kirill Simonov’s PyYAML.

For those of you who are unfamiliar with YAML, here is a concise description from the yaml.org welcome page:

YAML(tm) (rhymes with “camel”) is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals:

  • YAML documents are very readable by humans.
  • YAML interacts well with scripting languages.
  • YAML uses host languages’ native data structures.
  • YAML has a consistent information model.
  • YAML enables stream-based processing.
  • YAML is expressive and extensible.
  • YAML is easy to implement.

Here are some example of YAML taken from the current version of the YAML spec:

american:
  - Boston Red Sox
  - Detroit Tigers
  - New York Yankees     

national:
  - New York Mets
  - Chicago Cubs
  - Atlanta Braves     

-
  name: Mark McGwire
  hr:   65
  avg:  0.278     

-
  name: Sammy Sosa
  hr:   63
  avg:  0.288

Here is an example of decoding a YAML string and converting it to ActionScript objects:

With the following YAML stored in a file called myYaml.yaml

  ---
  Date: 2001-11-23 15:03:17 -5
  User: ed
  Fatal:
    Unknown variable "bar"
  Stack:
    - file: TopClass.py
      line: 23
      code: |
        x = MoreObject("345\n")
    - file: MoreClass.py
      line: 58
      code: |-
        foo = bar

You can load then load the YAML and decode it as follows.

   public function loadYaml() : void 
   { 
       var loader : URLLoader =  new URLLoader(); 
       loader.load(new URLRequest('myYaml.yaml')); 
       loader.addEventListener(Event.COMPLETE, onYamlLoad); 
   } 
  public function onYamlLoad(event : Event) : void 
  { 
       var yamlMap : HashMap = YAML.decode(event.target.data) as HashMap; // returns a HashMap 
       trace(yamlMap.get("Date"));  // returns a Date object and prints: Fri Nov 23 15:03:17 GMT-0500 2001 
       trace(yamlMap.get("User"));  // returns a String and prints: ed 
       trace(yamlMap.get("Fatal")); // returns a String and prints: Unknown variable "bar" 
       trace(yamlMap.get("Stack")); // returns an Array and prints: [object HashMap],[object HashMap] 
       trace(yamlMap.get("Stack")[0].get("line"));  // returns an Int and prints: 23 
       trace(yamlMap.get("Stack")[0].get("code"));  // returns a String and prints: x = MoreObject("345\n")     
 
  }

There are some more examples available in the as3yaml docs.

I have been working on this for a little while now, and running it through various tests, so I think it is at a point where it is ready to be released into the wild. Please submit any bugs that you find to the issues list on the google project site. If you have any interest in contributing to the project, please let me know.

 THANKS:

  • Of course, special thanks to Ola Bini and Kirill Simonov for their excellent work on jvyaml and PyYaml, respectively.
  • I would also like to thank the as3commons project.  This library made the port from Java quite a bit easier than it might have been. 

Aug 07 2007

method_missing in ActionScript 3/Flex

Tag: AS3, ActionScript, Flex, RubyDerek Wischusen @ 2:05 am

method_missing is one of the small bits of Ruby magic that can be used to some really amazing things when used properly, and some really dangerous things when used improperly. Rails dynamic finders are good example of the amazing things that you can do. Here are some others.

It is possible to implement something like method_missing in AS3 using the Proxy class. Here is a relatively simplistic example:

import flash.utils.Proxy;
import flash.utils.flash_proxy;
 
dynamic public class BaseProxy extends Proxy
{     
	flash_proxy override function callProperty(method: *, ...args): * {
	   try { 		 
	   var clazz : Class = getDefinitionByName(getQualifiedClassName(this)) as Class;
	    return clazz.prototype[method].apply(method, args);
	   }
	   catch (e : Error) {
		return methodMissing (method, args);
	   }
 
	}
 
	protected function methodMissing(method : *, args : Array) : Object{
		throw( new Error("Method Missing"));
	}
}

The callProperty method is called whenever an undefined method is called on an instance of this class, or any instance of class that extends this class. In the try block we check if the method was defined on the prototype. If it is not found there, we call methodMissing.

So, now if we create another class that extends this one like so

public dynamic class Model extends BaseProxy
{
	public function myMethod (arg1 : String, arg2 : Boolean) : String {
		return arg1 + " " + arg2;
	}
}

and then run the following trace statements

import flash.display.Sprite;
 
public class MethodMissingExample extends Sprite
{
	public function MethodMissingExample()
	{
		var m : Model =  new Model();
 
		Model.prototype.runtimeMethod = function (date : Date) : String {
			return "I was defined at runtime at " + date.toLocaleTimeString();
		};
 
		trace(m.myMethod("I exist", true));
                trace(m.runtimeMethod(new Date()));
		trace(m.someMethod(0, false, "x"));
	}
}

You will see the following in the console:

I exist true
I was defined at runtime at 09:58:00 PM
Error: Method Missing

The first call succeeds because myMethod is defined. someMethod is not defined, so a Method Missing error gets thrown.

Now, if we override the missingMethod in the Model class like so,

public dynamic class Model extends BaseProxy
{
	public function myMethod (arg1 : String, arg2 : Boolean) : String {
		return arg1 + " " + arg2;
	}
 
	override protected function methodMissing(method : *, args : Array) : Object {
		return "You called " + method + " with " + args.toString();
	}
}

and run the same trace statements you will see the following in the console:

I exist true
I was defined at runtime at 09:58:00 PM
You called someMethod with 0,false,x

Jun 15 2007

Static initializations in ActionScript, Take 2

Tag: ActionScriptDerek Wischusen @ 12:05 am

In a previous post I discussed how you can use the [Mixin] metadata tag to create a static initialization in Flex. Here is another way to do pretty much the same thing:

public dynamic class Model 
{ 
 
    trace('I get called first'); 
 
    public function Model() 
    { 
 
    } 
 
}

The trace statement and any other code that is directly inside the class body will be invoked when the class is loaded. You can read more about this here.


Discount viagra india
Prescription valium
Valium no rx
Valium from india
Purchase phentermine without prescription
Buying prednisone online
Buy generic valium
Phentermine 37.5 buy online
Levitra samples
Cheap levitra uk
Buy viagra online uk no prescription
Propecia 1mg generic
Free samples of cialis
Generic cialis uk
Tramadol without prescription overnight delivery
Order phentermine online no prescription
Canada viagra no prescription
Prednisone 20mg side effects
Order tramadol overnight
Viagra in the uk
Discount viagra pills
Levitra price
Authentic phentermine 37.5
Canada viagra
Online valium without prescription
Where to buy phentermine cheap
Phentermine buy uk
Drug phentermine

Phentermine 37.5mg
Buy propecia cheap
Order cheap viagra online
Buy tramadol cod
Buy phentermine 37.5mg pills
Buy xanax canada
Xanax 1 mg dose
Where to buy viagra online
Buy generic cialis uk
Buy tramadol hydrochloride
Viagra online cheap
Buying tramadol in uk
100mg tramadol effects
Valium pill 10mg
Valium 10 mg
No prescription cialis online
Buying viagra in london
Cialis price
Viagra without prescription uk
Cheap generic viagra
Levitra 20mg
Buy cheap viagra online uk
Viagra indian pharmacy
No prescription valium
Tramadol free shipping
Cialis order online
Purchase viagra online without prescription
Tramadol no prescription required
Viagra express delivery
Buy levitra
Australia viagra prescription
Cialis cialis
Viagra canadian online pharmacy
Cheapest cialis price
Buy generic cialis
Levitra canada
Where can i buy viagra in the uk
Viagra lowest prices
Cheap cialis soft tabs
Where to buy cialis safely
Best price cialis
Tramadol pharmacy
Cheap valium online
Cheap cialis india
Order prednisone no prescription
Generic xanax xr
Propecia cost
Best way to buy viagra online
Best levitra prices
Cheapest cialis professional
Xanax price per pill
Buy cialis in the uk
Phentermine online uk
Buy viagra 100mg
Fedex tramadol
Buy generic cialis online
Viagra super active
Valium online overnight
Viagra ordering
Prednisone tablets 10 mg
Cialis for sale
Propecia ireland
Cialis 10mg side effects
Valium generic
Buy phentermine hcl 37.5 no prescription
Viagra india price
Phentermine hcl without prescription
Cheap xanax for sale
10mg valium effects
Viagra price canada
Viagra buy online no prescription
Side effects of viagra
Purchase tramadol without prescription
Tramadol dosage
Viagra no prescription online
Generic viagra super active
100mg tramadol online
Valium online pharmacy
Viagra canada mastercard
Viagra dosage information
Xanax for sale without prescription
Buy viagra from canada
Xanax online cheap
Buy valium without prescription uk
10mg prednisone
Order xanax cod
Buy viagra online in ireland
Valium without prescription
Phentermine hcl no prescription
Cialis canada no prescription
Tramadol without prescription
Buying viagra online
Purchase phentermine online
Xanax generic dosage
Xanax 0.5 mg
Xanax bars side effects
Viagra fast delivery
Prescription viagra canada
Viagra purchase uk
Cialis soft tabs online
Xanax no rx
Viagra pharmacy prices
Xanax no prescription overnight
Where to buy levitra online
Buy cialis uk
Buy cialis online from canada
Mail order phentermine
Levitra online cheap
Prescriptions for phentermine
Buying cialis
Buy valium no rx
Ordering cialis online
Viagra shop online
Propecia uk pharmacy
Dose of xanax
Levitra online buy
Cheap tramadol cod
Xanax bars effects
Cheap levitra no prescription
Cheap generic valium
Real phentermine without prescription
How to buy valium without a prescription
Viagra canada online
Viagra 50mg side effects
Cheap viagra online without prescription
Viagra pharmacy uk
Phentermine diet pills without prescription
Phentermine without a prescription
Best price on phentermine
Buy propecia
Purchase tramadol online
Cialis samples canada
Cialis 20 mg dosage
Cialis 20mg
Discount viagra usa
Get tramadol prescription
Tramadol medication
Buy xanax online without prescription
Cost of viagra 50mg
Xanax 1mg side effects
Xanax with no prescription
Tramadol online no prescription overnight
Where to buy propecia in canada
Levitra us
Buy viagra online cheap
Generic cialis overnight
Prescription free viagra
Pfizer viagra price
Viagra in usa
Cheap cialis pills
Propecia information
Viagra 50 mg online without prescription
Where to buy cialis without prescription
Brand viagra cheap
Buy valium cheap online
Phentermine with no prescription
Buying xanax online without prescription
Online prescriptions xanax
Xanax 1mg
Viagra generic
Purchase levitra online
Cialis prescription cost
Cheap propecia without prescription
Buy viagra uk online
Overnight delivery viagra
Propecia price australia
Prednisone 40 mg
Buy tramadol overnight
Viagra canada prices
Propecia best prices
Phentermine 37.5 wholesale
Ordering propecia from canada
Overnight tramadol no prescription
Best viagra alternative
Viagra online uk
Buy brand name viagra
Order tramadol online cod
Order viagra without prescription
Prednisone online
Tramadol cod delivery
Phentermine 37.5 mg
Cialis ordering
Buy phentermine no script
Viagra discount coupons
Buy cialis brand
Propecia uk prices
Xanax overnight cod
Order xanax online
Phentermine cheap online
Buy cheap valium online
Overnight xanax delivery
Generic xanax no prescription
Levitra online
Cheapest place to buy viagra online
Buy phentermine online no prescription
Buy valium europe
Propecia cheap
Viagra tablets for sale
Levitra on sale
Buy generic phentermine online
Propecia usa
Generic tramadol
Buying viagra in new zealand
Generic propecia
Generic viagra online without prescription
Cheap cialis
Cialis dosage 20mg
Cheap tramadol overnight delivery
Cheapest online cialis
Valium cheapest
Buy generic xanax no prescription
Viagra to buy
Buying cialis online without a prescription
Buy xanax cheap online
Where can i buy cialis without a prescription
Viagra prescription cost
Buying valium in spain
Cheapest levitra
Best price tramadol
Buy xanax overnight
Phentermine canadian pharmacy